package cl.tinet.finalexam;

import java.io.Serializable;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import cd.tinet.finalexam.ejb.rooms.RoomsBeanInterface;
import cl.tinet.finalexam.ejb.user.UserBeanInterface;
import cl.tinet.finalexam.exceptions.RoomFoundException;
import cl.tinet.finalexam.exceptions.RoomNotFoundException;
import cl.tinet.finalexam.model.ClassroomModel;
import cl.tinet.finalexam.model.UserModel;

@ManagedBean
@ViewScoped
public class RoomsMB implements Serializable{

    @EJB(mappedName = "roombeanImpl", name = "roombeanImpl")
    private transient RoomsBeanInterface roomBean;
    
    private ClassroomModel roomSession;

    public RoomsMB() {
        if (roomSession == null) {
            roomSession = new ClassroomModel();
        }
    }
    
    public void addRoom(){
        roomBean.addRoom(roomSession);
    }
    
    public void removeRoom(){
        try{
        roomBean.removeRoom(roomSession);
        }catch (RoomFoundException e) {
            System.out.println("ERROR - Room Exist ID: " + e.getErr());
        }
    }
    
    
}
